#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

LL n,m;
LL dp[1024];
inline LL getDP(int i) {
    LL ret = (m+1)*dp[i-1] - m*dp[i-2];
    return ret;
}

int main() {
#ifdef hai
    freopen("in.txt", "r", stdin);
#endif
    int T;
    cin>>T;
    while (T--) {
        scanf("%lld %lld", &n, &m);
        dp[0] = 0; dp[1] = m;
        for (int i=2; i<=n; ++i) {
            dp[i] = getDP(i);
        }
        for (int i=0; i<=n; ++i){
            printf("%lld ", dp[i]);
        }
        printf("\n");
    }
    return 0;
}
